using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class NewsInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Category,
			CreateDay,
			Title,
			Image,
			ShortDecribes,
			LongDecribes,
			Source,
			CountPreview,
			IDStatus,
			Rank
		}
		private Int64 _ID;
		private String _Category;
		private Int32 _CreateDay;
		private String _Title;
		private String _Image;
		private String _ShortDecribes;
		private String _LongDecribes;
		private String _Source;
		private Int64 _CountPreview;
		private Int32 _IDStatus;
		private Int32 _Rank;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public String Category{	get{ return _Category;} set{_Category = value;} }
		public Int32 CreateDay{	get{ return _CreateDay;} set{_CreateDay = value;} }
		public String Title{	get{ return _Title;} set{_Title = value;} }
		public String Image{	get{ return _Image;} set{_Image = value;} }
		public String ShortDecribes{	get{ return _ShortDecribes;} set{_ShortDecribes = value;} }
		public String LongDecribes{	get{ return _LongDecribes;} set{_LongDecribes = value;} }
		public String Source{	get{ return _Source;} set{_Source = value;} }
		public Int64 CountPreview{	get{ return _CountPreview;} set{_CountPreview = value;} }
		public Int32 IDStatus{	get{ return _IDStatus;} set{_IDStatus = value;} }
		public Int32 Rank{	get{ return _Rank;} set{_Rank = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public NewsInfo()
		{
			_ID = 0;
			_Category = "";
			_CreateDay = 0;
			_Title = "";
			_Image = "";
			_ShortDecribes = "";
			_LongDecribes = "";
			_Source = "";
			_CountPreview = 0;
			_IDStatus = 0;
			_Rank = 0;
		}
		public NewsInfo(
		Int64 ID,
		String Category,
		Int32 CreateDay,
		String Title,
		String Image,
		String ShortDecribes,
		String LongDecribes,
		String Source,
		Int64 CountPreview,
		Int32 IDStatus,
		Int32 Rank
		)
		{
			_ID = ID;
			_Category = Category;
			_CreateDay = CreateDay;
			_Title = Title;
			_Image = Image;
			_ShortDecribes = ShortDecribes;
			_LongDecribes = LongDecribes;
			_Source = Source;
			_CountPreview = CountPreview;
			_IDStatus = IDStatus;
			_Rank = Rank;
		}
		public NewsInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_Category = dr[Field.Category.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Category.ToString()]);
				_CreateDay = dr[Field.CreateDay.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.CreateDay.ToString()]);
				_Title = dr[Field.Title.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Title.ToString()]);
				_Image = dr[Field.Image.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Image.ToString()]);
				_ShortDecribes = dr[Field.ShortDecribes.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ShortDecribes.ToString()]);
				_LongDecribes = dr[Field.LongDecribes.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LongDecribes.ToString()]);
				_Source = dr[Field.Source.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Source.ToString()]);
				_CountPreview = dr[Field.CountPreview.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.CountPreview.ToString()]);
				_IDStatus = dr[Field.IDStatus.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDStatus.ToString()]);
				_Rank = dr[Field.Rank.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Rank.ToString()]);
			}
		}
		public NewsInfo(NewsInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Category = objEntr.Category;			
			_CreateDay = objEntr.CreateDay;			
			_Title = objEntr.Title;			
			_Image = objEntr.Image;			
			_ShortDecribes = objEntr.ShortDecribes;			
			_LongDecribes = objEntr.LongDecribes;			
			_Source = objEntr.Source;			
			_CountPreview = objEntr.CountPreview;			
			_IDStatus = objEntr.IDStatus;			
			_Rank = objEntr.Rank;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("News");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Category.ToString(), typeof(String)),
				new DataColumn(Field.CreateDay.ToString(), typeof(Int32)),
				new DataColumn(Field.Title.ToString(), typeof(String)),
				new DataColumn(Field.Image.ToString(), typeof(String)),
				new DataColumn(Field.ShortDecribes.ToString(), typeof(String)),
				new DataColumn(Field.LongDecribes.ToString(), typeof(String)),
				new DataColumn(Field.Source.ToString(), typeof(String)),
				new DataColumn(Field.CountPreview.ToString(), typeof(Int64)),
				new DataColumn(Field.IDStatus.ToString(), typeof(Int32)),
				new DataColumn(Field.Rank.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Category.ToString()] = _Category;
			row[Field.CreateDay.ToString()] = _CreateDay;
			row[Field.Title.ToString()] = _Title;
			row[Field.Image.ToString()] = _Image;
			row[Field.ShortDecribes.ToString()] = _ShortDecribes;
			row[Field.LongDecribes.ToString()] = _LongDecribes;
			row[Field.Source.ToString()] = _Source;
			row[Field.CountPreview.ToString()] = _CountPreview;
			row[Field.IDStatus.ToString()] = _IDStatus;
			row[Field.Rank.ToString()] = _Rank;
			return row;
		}
        #endregion InitTable
    }
}
